import frappe
from frappe import _
from erpnext.accounts.doctype.payment_entry.payment_entry import PaymentEntry
original_make_advance_gl_entries=PaymentEntry.make_advance_gl_entries

def custom_make_advance_gl_entries(self, entry: object | dict = None, cancel: bool = 0, update_outstanding: str = "Yes"):
    if not cancel:
        self.is_opening="No"
    original_make_advance_gl_entries(self, entry, cancel, update_outstanding)

PaymentEntry.make_advance_gl_entries = custom_make_advance_gl_entries


